//
//  FirstView.m
//  引导页
//
//  Created by 王阳阳 on 16/3/23.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FirstView.h"

#define SCREEN_FRAME ([UIScreen mainScreen].bounds)
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)


@interface FirstView ()<UIScrollViewDelegate>
@property(nonatomic, assign)NSInteger number;
@end

@implementation FirstView




-(instancetype)initWithFrame:(CGRect)frame arr:(NSMutableArray*)arr{
    
    
    self  = [super initWithFrame:SCREEN_FRAME];
    if (self) {
        self.number = 3;
        self.bounces = NO;
        self.contentSize = CGSizeMake(SCREEN_WIDTH * arr.count, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor blackColor];
        self.showsHorizontalScrollIndicator = NO;
        self.pagingEnabled = YES;
        self.delegate = self;
        for (int i = 0; i < arr.count; i++) {
            UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
            //            [img setBackgroundColor:[UIColor redColor]];
            [img setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg",arr[i]]]];
            [self addSubview:img];
            if (i == arr.count - 1) {
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapAction:)];
                
                img.userInteractionEnabled = YES;
                
                [img addGestureRecognizer:tap];
            }
        }
    }
    return self;
}


-(void)handleTapAction:(UITapGestureRecognizer *)tap {
    
    
    
    [UIView animateWithDuration:2 animations:^{
        
        self.alpha = 0.0;
        
    } completion:^(BOOL finished) {
        
        [self removeFromSuperview];
        
    }];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
